﻿using System.Collections.Generic;
using System.Linq;
using BusinessLogic.Interfaces;
using Domain;
using Domain.Entities;

namespace BusinessLogic.Implementations
{
   public class EFCartRepository:ICartRepository
   {
       private EFDbContext context;
       public EFCartRepository(EFDbContext context)
       {
           this. context = context;
       }
       public IEnumerable<Cart> GetCarts()
       {
           return context.Carts.ToList();
       }

       public Cart GetCartById(int id)
       {
          return context.Carts.FirstOrDefault(i => i.Id == id);
       }

       public void DeleteCartById(int id)
       {
           context.Carts.Remove(GetCartById(id));
           context.SaveChanges();
       }
    }
}
